<!--  -->
<template>
  <div class="qq-music-mv">
    <h1>最 新 M V</h1>
    <ul>
      <li v-for="item in mvListName" :key="item.id">
        <a 
        href="javascript:;"
          @click="getmvlist(item.area)"
          :class="[{ green: isGreen === item.area }]"
        >{{ item.name }}</a>
        </li>
    </ul>
    <div class="mv-list">
      <div class="list" v-for="item in mvList" :key="item.id">
        <div class="list-box">
          <div class="imgbox">
            <div class="mask">
              <img
                src="https://y.gtimg.cn/mediastyle/yqq/img/cover_play@2x.png?max_age=2592000&v=88abebcbc1242dbbbbc836cc3e04a006&v=88abebcbc1242dbbbbc836cc3e04a006&v=10e4305a2558d496548955434eaa30d9"
                alt=""
              />
            </div>
            <img :src="item.cover" alt="" />
          </div>
          <p>{{ item.name }}</p>
          <span>{{ item.artistName }}</span>
          <span>播放量：{{ item.playCount }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      isGreen:'',
      area:'',
      mvList: [],
      mvListName: [
        {name:'精选',id:1,area:''},
        {name:'内地',id:2,area:'内地'},
        {name:'韩国',id:3,area:'韩国'},
        {name:'港台',id:4,area:'港台'},
        {name:'欧美',id:5,area:'欧美'},
        {name:'日本',id:6,area:'日本'},
      ],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    getmv: async function () {
      let res = await this.$http.get("mv/first", {
        params: {
          limit: 10,
          area:this.area,
        },
      });
      this.mvList = res.data.data;
      //   console.log(res);
    },
    getmvlist: function (area) {
      this.isGreen = area;
      this.area = area;
      this.getmv();
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.getmv();
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="less" scoped>
.qq-music-mv {
  margin-bottom: 40px;

  background: -webkit-linear-gradient(top, #eee, white);
  margin-bottom: 40px;
  margin: 0 auto;
  text-align: center;
  overflow: hidden;
  h1 {
    margin: 20px 0;
    font-weight: 500;
  }
  ul {
    display: flex;
    width: 600px;
    margin: 0 auto;
    justify-content: space-between;
    margin-bottom: 20px;
    li {
      list-style: none;
      a {
        text-decoration: none;
        color: #000;
      }
      a:hover {
        color: #31c27c;
      }
      .green {
        color: #31c27c;
      }
    }
  }
  .mv-list {
    display: flex;
    justify-content: space-between;
    width: 1200px;
    flex-wrap: wrap;
    margin: 0 auto;
    .list {
      .list-box {
        margin-bottom: 20px;
        .imgbox {
          width: 220px;
          height: 130px;
          position: relative;
          overflow: hidden;
        cursor: pointer;
          .mask {
            width: 220px;
            height: 130px;
            opacity: 0;
            position: absolute;
            transition: all 0.5s linear;
            background: rgba(30, 30, 30, 0.2);
            img {
              position: absolute;
              top: 36px;
              left: 88px;
              width: 50px;
              height: 50px;
            }
          }
          img {
            width: 220px;
            height: 130px;
            transition: all 0.5s linear;
            margin-bottom: 10px;
          }
        }
        .imgbox:hover {
          .mask {
            opacity: 1;
            z-index: 999;
          }
          img {
            transform: scale(1.1);
          }
        }
        p {
          font-size: 14px;
          width: 220px;
          text-align: left;
          margin-top: 4px;
        cursor: pointer;
        }
        p:hover{
            color: #31c27c;
        }
        span {
          text-align: left;
          font-size: 14px;
          color: #999;
          margin-top: 4px;
          display: block;
        cursor: pointer;
        }
        span:hover{
            color: #31c27c;
        }
      }
    }
  }
}
</style>